<template>
	<view class="home">
		<ty-tab-around :list="typeList" :list-key="listKey" :active.sync="typeIndex" @click="changeType"
			lineColor="#1a1a1a">
		</ty-tab-around>
		<ty-tab-around :list="tabsList" :list-key="listKey" :active.sync="tabIndex" @click="changeTabs"
			lineColor="#1a1a1a">
		</ty-tab-around>
		<view class="" v-if="typeIndex==0">
			<view class="box padding-30  margin-lr-30 bg-ff radius-40 margin-bottom-40 bg-shadow"
				v-for="(item,index) in list" :key="index" @click="go('/pages/order/orderDetail?id='+item.id)">
				<view class="box_top">
					<view>订单编号：{{item.order_no}}</view>
					<view style="color: #ff0000;" v-if="item.status==0">待支付</view>
					<view style="color: #ff0000;" v-if="item.status==1">待发货</view>
					<view style="color: #46cf5d;" v-if="item.status==2">待收货</view>
					<view style="color: #000;" v-if="item.status==3">已完成</view>
					<view style="color: #666 ;" v-if="item.status==4">已取消</view>
					<view style="color: #ff0000;" v-if="item.status==5">退货退款</view>
				</view>
				<view class="box_bottom">
					<view class="box_goods">
						<view class="box_goods_item" v-for="(ite,ind) in item.item" :key="ind">
							<image :src="ite.goodimage" mode=""></image>
							<view class="box_goods_name">{{ite.goodname}}</view>
							<view>x{{ite.num}}</view>
						</view>
					</view>
					<view class="box_right">
						<view>
							合计￥
							<text style="font-size:32rpx;">{{item.total}}</text>
						</view>
						<view style="color:#999;">共{{item.count}}种商品</view>
					</view>
				</view>
			</view>
		</view>
		<view class="" v-if="typeIndex==1">
			<view class="box padding-30  margin-lr-30 bg-ff radius-40 margin-bottom-40 bg-shadow"
				v-for="(item,index) in list" :key="index" @click="go('/pages/order/integratedetail?id='+item.id)">
				<view class="box_top">
					<view>订单编号：{{item.order_no}}</view>
					<view style="color: #ff0000;" v-if="item.status==0">待支付</view>
					<view style="color: #ff0000;" v-if="item.status==1">待发货</view>
					<view style="color: #46cf5d;" v-if="item.status==2">待收货</view>
					<view style="color: #000;" v-if="item.status==3">已完成</view>
					<view style="color: #666 ;" v-if="item.status==4">已取消</view>
					<view style="color: #ff0000;" v-if="item.status==5">退货退款</view>
				</view>
				<view class="box_bottom">
					<view class="box_goods">
						<view class="box_goods_item" v-for="(ite,ind) in item.item" :key="ind">
							<image :src="ite.goodimage" mode=""></image>
							<view class="box_goods_name">{{ite.goodname}}</view>
							<view>x{{ite.num}}</view>
						</view>
					</view>
					<view class="box_right">
						<view>
							合计￥
							<text style="font-size:32rpx;">{{item.amount}}</text>
						</view>
						<!-- <view style="color:#999;">共{{item.count}}种商品</view> -->
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 标签显示字段值
				listKey: 'name',
				// 订单状态标签栏
				tabsList: [{
					name: '全部',
					index: 0
				}, {
					name: '待发货',
					index: 1
				}, {
					name: '待收货',
					index: 2
				}, {
					name: '已完成',
					index: 3
				}, {
					name: '其他',
					index: 4
				}],
				tabIndex: 0,
				typeList: [{
					name: '会员商城',
					index: 0
				}, {
					name: '妖币商城',
					index: 1
				}],
				typeIndex: 0,
				list: [],
				last_page: 0,
				current_page: 1,
			}
		},
		onShow() {
			this.init(1)
		},
		onReachBottom() {
			this.init(0)
		},
		methods: {
			changeType(e) {
				this.typeIndex = e.index
				this.init(1)
			},
			changeTabs(e) {
				this.tabIndex = e.index
				this.current_page = 1
				this.init(1)
			},
			init(isFirstPage) {
				var that = this
				if (that.typeIndex == 0) {
					that.rq.getList('Memorder/order_list', {
						type: this.tabIndex == 0 ? '' : this.tabIndex - 1,
					}, {
						that: that,
						first_page: isFirstPage
					})
				} else {
					that.rq.getList('sign/order_list', {
						type: this.tabIndex == 0 ? '' : this.tabIndex - 1,
					}, {
						that: that,
						first_page: isFirstPage
					})
				}

			},
		}

	}
</script>

<style lang="scss" scoped>
	.home {
		width: 100%;
		min-height: 100vh;
		background: #fff;
	}

	.box {
		.box_top {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding-bottom: 20rpx;
			margin-bottom: 20rpx;
			border-bottom: 1rpx solid #eaeaea;
			font-size: 26rpx;
			color: #666666;
		}

		.box_bottom {
			display: flex;
			justify-content: space-between;
			align-items: center;

			.box_goods {
				display: flex;
				align-items: center;
				width: 0;
				flex: 1;
				overflow: auto;
				margin-right: 20rpx;

				.box_goods_item {
					width: 150rpx;
					margin-right: 20rpx;
					font-size: 26rpx;
					color: #666666;

					image {
						width: 150rpx;
						height: 150rpx;
						border-radius: 10rpx;
					}

					.box_goods_name {
						width: 100%;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
					}
				}
			}

			.box_right {
				width: 230rpx;
				display: flex;
				flex-direction: column;
				align-items: flex-end;
				font-size: 24rpx;
			}
		}
	}
</style>